package com.zwy.Shopping.servlet_;

import com.zwy.Shopping.dao.ProductDao;
import com.zwy.Shopping.dao.impl.ProductDaoImpl;
import com.zwy.Shopping.model.Product;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
@WebServlet("/now_shopping_get_product")
public class NowShoppingGetProductServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //获取服务器中的productId
        String productId = request.getParameter("productId");
            System.out.println(productId);
        ProductDao productDao = new ProductDaoImpl();
        Product product = productDao.getProductById(Integer.parseInt(productId));
        request.getSession().setAttribute("now_shopping_product",product);
        System.out.println(product);
        //request.getRequestDispatcher("login.jsp").forward(request,response);


    }
}
